//
//  JXSwiftExtention.swift
//  lxd
//
//  Created by Aaron on 2018/3/2.
//  Copyright © 2018年 陈晨昕. All rights reserved.
//

import UIKit

class JXSwiftExtention: NSObject {

}

//MARK: - Global Common Function
func SCREEN_WIDTH() -> CGFloat{
    return UIScreen.main.bounds.size.width
}

func SCREEN_HEIGHT() -> CGFloat{
    return UIScreen.main.bounds.size.height
}

func SCREEN_BOUNDS() -> CGRect{
    return UIScreen.main.bounds
}

//SYSTEM CLASS EXTENTION
extension Array where Element: Equatable {
    
    mutating func remove(object: Element) {
        
        if let index = index(of: object) {
            
            remove(at: index)
        }
    }
}

extension UIColor {
    
   class func RGBA_COLOR(red:CGFloat , green:CGFloat,blue:CGFloat,alpha:CGFloat) -> UIColor {
        
        return UIColor(red: red/255.0, green:green/255.0 , blue: blue/255.0, alpha: alpha)
        
    }
    
   class func HEX_COLOR(HEX_Value: Int , alpha:CGFloat) -> (UIColor) {
        return UIColor(red: ((CGFloat)((HEX_Value & 0xFF0000) >> 16)) / 255.0,
                       green: ((CGFloat)((HEX_Value & 0xFF00) >> 8)) / 255.0,
                       blue: ((CGFloat)(HEX_Value & 0xFF)) / 255.0,
                       alpha: alpha)
    }
}

extension UIImage{
    
    class func convertViewToImage(view:UIView) -> UIImage {
        
        let size = view.bounds.size
        
        UIGraphicsBeginImageContextWithOptions(size, true, UIScreen.main.scale)
        
        view.layer.render(in: UIGraphicsGetCurrentContext()!)
        
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return image!

    }
    
}

//MARK: - Other Common Function
func loadNib(nibName:String) -> [Any]? {
    
  return Bundle.main.loadNibNamed(nibName, owner: nil, options: [:])
    
}
